<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
		+ request.getServerName() + ":" + request.getServerPort()
		+ path + "/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>选择供应商</title> 
    <%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
	     <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script> 
	 
	<script type="text/javascript">
		$(document).ready(function() {
			/**
			 * 供应商列表
			 */
			$("#gridTable").jqGrid( {
				url : '<%=request.getContextPath() %>/equipmentParts!queryGYS.action',
				datatype : "json",
				width : 480,
				height : 250,
				colNames:["供应商ID","供应商名称","供应商地址"],
		        colModel:[
		            {name:'ID',index:'ID',key:true,hidden:true},
					{name:'GYS_NAME',index:'GYS_NAME',width:150},
					{name:'GYS_DIZHI',index:'GYS_DIZHI',width:200}
		        ], 
				shrinkToFit:false,
				sortname:'ID',
				sortorder:'desc',
				viewrecords:true,
				multiselect: true, // 是否显示复选框
				multiboxonly : true, 
				//gridview: true,  //提升速度
				rownumbers: true,//显示行号
				rownumWidth: 30, //行号的宽度
				ondblClickRow : function(rowid) {
					var row = $("#gridTable").jqGrid('getRowData', rowid);
					window.returnValue = row;
				    window.close();
				},
				rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
				rowList:[10,20,50,200,500],
				toolbar: [false,"top"],
				jsonReader: {
					root:"rows",		// 数据行（默认为：rows）
					page: "page",  	// 当前页
					total: "total",  // 总页数
					records: "records",  // 总记录数
					repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
				},
				prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
				pager:"#gridPager",
				caption : "供应商列表"
			});
		
		
			
		
			/**
			 * 确定
			 */
			$("#entry").click(function() {
			    var result = [];
			    var rowid= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
				if (!rowid) {
				    alert("请先选择记录!");  
				    return false;  
				} 
				if(rowid.indexOf(",")!=-1){
					  alert("只能选择一条记录!");  
				      return false; 
				 }
				var row= $("#gridTable").jqGrid("getRowData", rowid);
				window.returnValue = row;
				window.close();
			});
		
			/**
			 * 取消
			 */
			$("#center").click(function() {
				window.close();
			});
		});
		/**
		 * 查询
		 */
		var gridSearch = function() {
			var epName = $("#gysName").val();
		
			var params = {
				"gysName" : encodeURIComponent(gysName)
			};
		
			var postData = $("#gridTable").jqGrid("getGridParam", "postData");
			$.extend(postData, params); // (9)将postData中的查询参数覆盖为空值
			$("#gridTable").jqGrid('setGridParam', {
				url :"<%=request.getContextPath() %>/equipmentParts!queryGYS.action"
			}).trigger("reloadGrid", [ {
				page : 1
			} ]);
		}
		
		// 清空
		var reset = function() {
			jQuery("#gysName").val('');
		}
    </script> 
    </head>
  <body>
  	<form method="post" id="form1">
  	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  	  <tr>
				<td  align="right">供应商名称:</td><td  align="left"><input type="text" id="gysName" style="width: 90px;"/></td>
			    <td>
					<input type="button" class="button_b" value="查&nbsp;询" onclick="gridSearch()"/>
					<input type="button" class="button_b" value="清&nbsp;空" onclick="reset()"/>
				</td>
			</tr>
  	</table>
  	<table id='gridTable'></table><div id='gridPager'></div>
  	</form>
    <div style="clear: both;text-align: center;background-color:#b7dbf3;">
        <button id="entry" class="button_b">确&nbsp;定</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button id="center" class="button_b">取&nbsp;消</button>
    </div>
  </body>
</html>